package design.simdi.code.final_paper.site.panels.administrare.absolventi;

import org.apache.wicket.Page;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;

import design.simdi.code.final_paper.core.entities.Person;
import design.simdi.code.final_paper.site.panels.OneButtonPanel;

/**
 * 
 * @author Marius Dumitriu - (Jun 25, 2010 - 7:36:55 PM)
 * 
 */
public class ViewAbsolventDetails extends OneButtonPanel {

	private static final long serialVersionUID = 1L;
	private Person absolvent;

	public ViewAbsolventDetails(String id, IModel<Person> model) {
		super(id, model);

	}

	@Override
	public void panelInit() {
		super.panelInit();
		setOutputMarkupId(true);
		absolvent = (Person) getDefaultModelObject();

		getForm().add(new Label("an", new PropertyModel<Integer>(absolvent.getAbsolvent(), "anAbsolvire")));
		getForm().add(new Label("fullName", new Model<String>(absolvent.toString())));
		getForm().add(new Label("email", new PropertyModel<String>(absolvent.getUser(), "email")));

	}

	@Override
	public void onCANCELButtonSubmit(AjaxRequestTarget target) {
		AbsolventiTabPanel panel = new AbsolventiTabPanel("panel");
		panel.setOutputMarkupId(true);

		Page page = this.getPage();

		page.get("content:tabs:panel").replaceWith(panel);

		target.addComponent(page);
	}

}
